package com.putong35.common.httprequest.responsecallbacks;

/**
 * SingleBeanResponseListener
 * 1. 指定JavaBean类型和Class变量
 * 2. 父类的onSuccess不让使用
 *
 * @Author: Peng Weiwei
 * @E-mail: pengveivei@sina.cn
 * @CreateDate: 2017-6-5
 * @Version: 1.0.0
 */
public abstract class SingleBeanResponseListener<BeanT> extends StringResponseListener {
    Class<BeanT> beanTClass;

    public SingleBeanResponseListener(Class<BeanT> beanTClass) {
        this.beanTClass = beanTClass;
    }

    public abstract void onSuccess(BeanT bean);

    @Override
    public void onSuccess(String response) {
        throw new RuntimeException("不可以回调此接口");
    }


    @Override
    public void deliverSuccessResponse(String response) {
        BeanT bean = getResponse().getDataBean(beanTClass);
        onSuccess(bean);
    }
}
